﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Admin.Core.Common.Input;
using Admin.Core.Common.Output;
using Admin.Core.Common.ParamInput;
using Admin.Core.Service.Xsproject.Project;
using Admin.Core.Service.Xsproject.TaskHis;
using Admin.Core.Service.Xsproject.TaskHis.Input;
using Admin.Core.Service.Xsproject.TaskItem;
using Admin.Core.Service.Xsproject.TaskItem.Input;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Admin.Core.Controllers.Project
{
    /// <summary>
    /// 任务负责人接口
    /// </summary>
    public class TaskItemController : AreaController
    {
        private readonly IProjectService _projectService;
        private readonly ITaskItemService _taskItemService;
        private readonly ITaskHisService _taskHisService;
        
        public TaskItemController(IProjectService projectService, ITaskItemService taskItemService, ITaskHisService taskHisService)
        {
            _projectService = projectService;
            _taskItemService = taskItemService;
            _taskHisService = taskHisService;
        }


        /// <summary>
        /// 查询任务负责任务信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<ConmonFilterInput> model)
        {
            return await _taskItemService.PageAsync(model);
        }

        /// <summary>
        /// 任务开启
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> TaskBegin(TaskBeginInput input)
        {
            return await _taskItemService.TaskBeginAsync(input);
        }


        /// <summary>
        /// 查询修改任务信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetUpTask(long id)
        {
            return await _taskItemService.GetUpTaskAsync(id);
        }

        /// <summary>
        /// 更新任务记录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> AddHis(TaskHisAddInput input)
        {
            return await _taskHisService.AddAsync(input);
        }


        /// <summary>
        /// 查询任务更新历史
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetTaskHisPage(PageInput<ConmonFilterIdInput> model)
        {
            return await _taskHisService.PageAsync(model);
        }
    }
}
